using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Spring : MonoBehaviour
{
    public float k = 50f;
    public float fric = 24f;
    public Vector3 mVelocity;
    public Vector3 offset;
    public Vector3 offset_1;
    public Transform target;


    void Update()
    {
        if (target == null)
        {
            return;
        }
        var f = ((offset+ offset_1 + this.transform.position) - target.transform.position) * k;
        mVelocity += f * Time.deltaTime;
        mVelocity = Vector3.Lerp(mVelocity, Vector3.zero, fric * Time.deltaTime);

        target.transform.position += mVelocity;
    }

    //void OnTriggerEnter(Collider other)
    //{
    //    mVelocity = (other.transform.position - transform.position).normalized * force;
    //}
}
